﻿using System.Threading.Tasks;
using SmartCity.Shared;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;

namespace CommonManagement
{
    /// <summary>
    /// 充值记录管理类
    /// </summary>
    public class RechargeManager : DomainService
    {
        private readonly IRepository<Recharge, int> _rechargeRepository;

        public RechargeManager(
            IRepository<Recharge, int> rechargeRepository)
        {
            _rechargeRepository = rechargeRepository;
        }

        public async Task<Recharge> CreateAsync(
            int userId,
            int money,
            PaymentType? payType)
        {
            return await _rechargeRepository.InsertAsync(
                new Recharge(
                    userId,
                    money,
                    payType
                )
            );
        }
    }
}